<?php
header('content-type:text/html;charset=utf-8');
$user = $_POST['username'];
$pass = $_POST['password'];
$con = mysqli_connect('localhost','root','root','class');
if($con) {
    $sql = "select * from user where name = '$user' and password = '$pass'";
    $res = mysqli_query($con,$sql);
    $num = mysqli_num_rows($res);
    if($num == 0) {
        echo 0;
    } else {
        echo 1;
    }
} else {
    echo '连接失败！';
}
mysqli_close($con);
?>